package com.rest.demo.config;

import com.rest.demo.config.properties.HikariProperties;
import com.zaxxer.hikari.HikariDataSource;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author Administrator
 * @decription
 * @Date 2018-02-06 14:33
 */
@Configuration
@EnableTransactionManagement
@MapperScan(basePackages = {"com.rest.demo.mybatisdemo.mapper.mapping"})
public class MybatisConfig {

    @Autowired
    private HikariProperties hikariProperties;

    private HikariDataSource hikariDataSource() {
        HikariDataSource hikariDataSource = new HikariDataSource();
        hikariProperties.config(hikariDataSource);
        return hikariDataSource;
    }

    @Bean
    public HikariDataSource dataSource() {
        return hikariDataSource();
    }

}
